package com.itcat.controller;


import com.itcat.common.CommonResult;
import com.itcat.interceptor.UserHolder;
import com.itcat.mysql.pojo.Upload;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;


@RestController
@RequestMapping("/oss")
public class OssController {

    @Value("${mall.oss.key}")
    private String key;

    @Value("${mall.oss.host}")
    private String host;

    /***
     * 图片上传
     * @author Cr Mr
     * @date 2022/4/4 21:55
     */
    @GetMapping("policy")
    public CommonResult updatePhoto() throws IOException {
        Upload upload = new Upload();
        upload.setSignature(key);
        upload.setDir(String.valueOf(UserHolder.getUserId()));
        upload.setHost(host);
        return CommonResult.success(upload);
    }
}